package dyyx.guava;

import java.text.SimpleDateFormat;
import java.util.Date;

import com.google.common.util.concurrent.RateLimiter;

public class RateLimiterTest {
	
	private static final String DATEFORMAT = "yyyy.MM.dd HH:mm:ss SSS";
	
	
	
	public static void main(String[] args) throws Exception {		
	    RateLimiter limiter = RateLimiter.create(3);
	    long start = System.currentTimeMillis();
	    
	    SimpleDateFormat sdf = new SimpleDateFormat(DATEFORMAT);
	    
	    while(true){	    	
	    	System.out.println(limiter.tryAcquire()+","+sdf.format(new Date()));
	    	Thread.sleep(20);
	    	
	    	/*
	        long now = System.currentTimeMillis();
	        if((now - start) > 1100){
	        	break;
	        }
	        */
	    }

	}
}
